﻿using System.ComponentModel.DataAnnotations;
using FluentNHibernate.Mapping;

namespace MVVMtutorialAdvanced.Web
{
	public class BookAuthor : EntityBase<BookAuthor>
	{
		//[Key]
		//public virtual int Id { get; set; }

		// Include and Association must be used, if this Class is used for Data Transfer in parent object Book.
		// Problem: If parent object is returned for Update, all included Book-Objects will be null -> Error in RIA.NET 4.0

		//[Include]
		//[Association("Relation1", "BookId", "Id")]
		public virtual Book Book { get; set; }

		public virtual Author Author { get; set; }
	}

	public class BookAuthorMap : ClassMap<BookAuthor>
	{
		public BookAuthorMap()
		{
			Id(x => x.Id);
			References(x => x.Book);
			References(x => x.Author);
		}
	}
}